package magazyn.model;

import java.io.Serializable;
import java.sql.Date;

import magazyn.model.Produkty;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "zamowienie")
public class Zamowienie implements Serializable{
	
	private static final long serialVersionUID = 1L;
	private int id_zamowienia;
	private int biezace;
	private Produkty id_prod;
	private int ilosc;
	private Date data;
	
	public Zamowienie(){}
	
	

	public Zamowienie(int biezace, Produkty id_prod, int ilosc, Date data) {
		super();
		this.biezace = biezace;
		this.id_prod = id_prod;
		this.ilosc = ilosc;
		this.data = data;
	}



	@Id
	@GeneratedValue
	@Column(name="id_zamowienia")
	public int getId_zamowienia() {
		return id_zamowienia;
	}

	public void setId_zamowienia(int id_zamowienia) {
		this.id_zamowienia = id_zamowienia;
	}

	@Column(name = "biezace")
	public int getBiezace() {
		return biezace;
	}
	public void setBiezace(int biezace) {
		this.biezace = biezace;
	}
	

	

    @OneToOne(targetEntity=Produkty.class, cascade = CascadeType.ALL)
    @JoinColumn(name = "id_prod", referencedColumnName="id_produktu" )
	public Produkty getId_prod() {
		return id_prod;
	}
	
	public void setId_prod(Produkty id_prod) {
		this.id_prod = id_prod;
	}
	
	
	 @Column(name = "ilosc")
	public int getIlosc() {
		return ilosc;
	}
	
	public void setIlosc(int ilosc) {
		this.ilosc = ilosc;
	}
	
	 @Column(name = "data")
	public Date getData() {
		return data;
	}
	public void setData(Date data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "Zamowienie [id_zamowienia=" + id_zamowienia + ", biezace="
				+ biezace + ", id_prod=" + id_prod + ", ilosc=" + ilosc
				+ ", data=" + data + "]";
	}

	
	
	
}
